package com.drcoffee.drcoffeemall.controller;

import com.drcoffee.drcoffeemall.entry.Machine;
import com.drcoffee.drcoffeemall.entry.Video;
import com.drcoffee.drcoffeemall.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/video")
public class VideoController {
    @Autowired
    VideoService videoService;


    /*
     * 查询视频
     * */
    @GetMapping("/getVideo")
    public Map<String, Object> getVideo(@RequestParam(required = false) Integer machine_id, @RequestParam String search) {
        return videoService.getVideo(machine_id, search);
    }

    /*
     * 查询所有视频
     * */
    @GetMapping("/getVideoAll")
    public Map<String, Object> getVideoAll() {
        return videoService.getVideoAll();
    }

    /*
     * 添加视频
     * */
    @PostMapping("/addVideo")
    public Map<String, Object> addVideo(@RequestBody Video video) {
        return videoService.addVideo(video);
    }

    @PostMapping("/updateVideo")
    public Map<String, Object> updateVideo(@RequestBody Video video) {
        return videoService.updateVideo(video);
    }

    @PostMapping("/updateVideoText")
    public Map<String, Object> updateVideoText(@RequestBody Video video) {
        return videoService.updateVideoText(video);
    }

    @GetMapping("/deleteOld")
    public Map<String, Object> deleteOld(@RequestParam Integer id) {
        return videoService.deleteOld(id);
    }

}
